//
//  MPRegisterViewController.m
//  SearchPeople
//
//  Created by YoloMao on 16/5/10.
//
//

#import "MPRegisterViewController.h"
#import "MPImport.h"

@interface MPRegisterViewController ()

@property (weak, nonatomic) IBOutlet UITextField *usernameTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;

@end

@implementation MPRegisterViewController

#pragma mark - UIViewController Life Cycle

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - Action

- (IBAction)registerButtonClick:(id)sender
{
    if (![[MPSettingsManager getInstance] isValidateMobile:self.usernameTextField.text])
    {
        [SVProgressHUD showErrorWithStatus:@"请输入正确的手机号"];
        return;
    }
    if (![[MPSettingsManager getInstance] judgePassword:self.passwordTextField.text])
    {
        [SVProgressHUD showErrorWithStatus:@"密码为6-18位的数字或字母组合"];
        return;
    }
    [[MPDocumentHttpClient shareInstance] RegisterWithUsername:self.usernameTextField.text
                                                  WithPassword:self.passwordTextField.text
                                              WithSuccessBlock:^(MPRequest *request, MPResponse *response)
    {
         [SVProgressHUD showSuccessWithStatus:@"注册成功"];
         [self.navigationController popViewControllerAnimated:YES];
        
    } WithFailedBlcok:^(MPRequest *request, MPResponse *response)
    {
        [SVProgressHUD showErrorWithStatus:@"注册失败"];
    }];
}

@end
